package com.ruoyi.project.system.table.domain;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.exception.DataException;
import com.ruoyi.project.system.dict.utils.DictUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;

/**
*
*
* @Author: 郑吉志
*
* @Create: 23.2.22
**/
@Data
public class BusiTable
{
    // 户编号，姓名，证件号码，自然村，年度，操作
    Integer id;
    String fid;
    String name;
    String idCard;
    //字典值
    Integer natVillage;
    Integer reportYear;

    public BusiTable() {
    }

    public BusiTable(Table table) {
        if (table==null){
            this.fid=null;
            this.name=null;
            this.idCard=null;
            this.natVillage=null;
            this.reportYear=null;
        }
        else {
            this.fid = table.fid;
            this.name = table.name;
            this.idCard = table.getIdCard();
            if (table.getNatVillage() == null)
                this.natVillage = null;
            else
                //根据字典与其对应的名称来确定自然村对应字典的值
                this.natVillage = Integer.parseInt(DictUtils.getDictValue("base_nature_village", table.getNatVillage()));
            if (table.getReportYear() == null || table.getReportYear().equals(""))
                this.reportYear = null;
            else{
                if (StringUtils.isNumeric(table.getReportYear()))
                    this.reportYear = Integer.parseInt(table.getReportYear());
                else
                    throw new DataException("年度不是数字");
            }
        }
    }
}
